package com.demo.hdfs.fs;

import com.demo.hdfs.FileUtils;

import java.io.*;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        FileUtils fileUtils = new DistributeFileSystemUtil();
        String basepath = "/usr/demo/hdfs/";
        fileUtils.mkdir(basepath);
        File file = new File("D:\\git\\hadoop-cloudera-demo\\src\\main\\java\\com\\demo\\hdfs\\fs\\abc.txt");
//        try {
//            FileInputStream fileInputStream = new FileInputStream(file);
//            fileUtils.putHDFS(fileInputStream,basepath+file.getName());
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
        //貌似因为FileSystem没有关闭，刚上传的文件还没有真正的写入信息，所以会获取值失败
        List<String> stringList = fileUtils.listFile(basepath);
        stringList.forEach(System.out::println);

        String hdfs = fileUtils.getHdfs(basepath + file.getName());
        System.out.println(hdfs);

    }
}
